{{ .dataGrid }}
<div id="setting_cache_datagrid_toolbar" style="padding:5px;height:auto">
    <form><a href="javascript:;" onclick="settingCacheDelete('all');" class="easyui-linkbutton" iconCls="icons-other-delete">清理选中缓存</a></form>
</div>


<script>
    function settingCacheOperateFormatter(key) {
        console.log(arguments)
        return '<a href="javascript:;" class="btn btn-danger btn-sm" onclick="settingCacheDelete(\'' + key + '\')">清理</a>'
    }

    function settingCacheDelete(key) {
        $.messager.confirm('提示信息', '确定要删除缓存吗？', function (result) {
            if (!result) return false;
            if (key === 'all') {
                key = getSelectedCacheKey().join(",")
                if (key === "") {
                    return false;
                }
            }
            $.post('/b/setting/del-cache', {key: key}, function (res) {
                if (res.errcode) {
                    $.messager.alert('提示信息', res.errmsg, 'error');
                } else {
                    $.messager.alert('提示信息', res.errmsg, 'info');
                }
            }, 'json');
        });
    }

    function getSelectedCacheKey() {
        var objs = $("#setting_cache_datagrid").datagrid("getChecked");
        var tableNames = [];
        objs.forEach((value) => {
            tableNames.push(value.key)
        })
        return tableNames
    }

</script>